package com.gardenguell.salad.app;

import android.os.Handler;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by absurd on 2015/11/14.
 */
public class HandlerCenter {

    private ConcurrentHashMap<Integer , Handler> mHandlers;

    private static HandlerCenter mHandlerCenter;

    public synchronized static HandlerCenter getInstance(){
        if(mHandlerCenter == null)
            mHandlerCenter = new HandlerCenter();
        return mHandlerCenter;
    }

    public Handler getHandler(int flag){
        if(mHandlers == null){
            mHandlers = new ConcurrentHashMap<Integer , Handler>();
        }
        return mHandlers.get(flag);
    }


    public void setHandler(int flag, Handler handler){
        if (mHandlers == null){
            mHandlers = new ConcurrentHashMap<Integer , Handler>();
        }
        mHandlers.put(flag, handler);
    }

    public interface Flag{
        int BASE_ACTIVITY = 1;
        int MAIN_ACTIVITY = 2;
        int MAIN_FRAGMENT = 3;
        int UNIT_FRAGMENT = 4;
    }

    public interface Message{
        int DISMISS_PROGRESS = 1;
        int SHOW_PROGRESS = 2;
        int TO_BOX_ACTIVITY = 3;
        int ADD_NEW_BOX = 4;
        int CONFIG_WIFI = 8;
        int REFRESH_BOX_LIST = 5;
        int WRONG_TOKEN = 6;
        int REFRESH_UNIT_LIST = 7;
        int SHOW_TOAST = 9;
        int CLICK_WARNING = 10;
    }


}
